package org.ycsoft.PathComputation;

/**
 * This class represent a bundle of the stop and its key (the distance) in the priority queue
 * @author allad
 *
 */
public class PriorityQueueItem{
	
	private int key;
	private Stop stop;
	
	public PriorityQueueItem(Stop stop,int key){
		this.stop = stop;
		this.key = key;
	}
	
	public int getDistance(){
		return key;
	}
	
	public Stop getStop(){
		return stop;
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString(){
		return stop+","+key;
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	public boolean equals(Object o){
		if(o == null)
			return false;
		else if(o instanceof PriorityQueueItem){
			PriorityQueueItem pi = (PriorityQueueItem)o;
			//2 items are equals only if their stops are equaln
			return this.stop.equals(pi.stop);
		}
		else if(o instanceof Stop){
			Stop s = (Stop)o;
			return this.stop.equals(s);
		}
		else return false;
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode(){
		return stop.hashCode();
	}
}